
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

public class FileHandler {
	
	private String location;
	private String chosenFormat;
	
	public FileHandler(String s){location = s;}
	public void setFileHandler(String s){location = s;}
	public String getFormat(){return chosenFormat;}
	
	/**
	 * Code from KodeJava has been modified.
	 * http://www.kodejava.org/examples/28.html
	 * 11-02-10
	 * 
	 * @param s
	 */
	public String[] readFile(){
		
		 	File file = new File(location);
	        StringBuffer contents = new StringBuffer();
	        BufferedReader reader = null;
			
	        try
	        {
	            reader = new BufferedReader(new FileReader(file));
	            String text = null;
	            
	            while ((text = reader.readLine()) != null)
	            {
	                contents.append(text)
	                    .append(System.getProperty(
	                        "line.separator"));
	            }
	        } catch (FileNotFoundException e)
	        {
	            e.printStackTrace();
	        } catch (IOException e)
	        {
	            e.printStackTrace();
	        } finally
	        {
	            try
	            {
	                if (reader != null)
	                {
	                    reader.close();
	                }
	            } catch (IOException e)
	            {
	                e.printStackTrace();
	            }
	        }
	        
	        /**
			* From:
			* http://bytes.com/topic/java/insights/618869-splitting-strings
			*/

	      	String[] tokens = contents.toString().split("\n");
			
			/*for(int i = 0; i <= tokens.length-1; i++) {
				 System.out.println(tokens[i]);
			}*/
	        
	        // show file contents here
	       // System.out.println(contents.toString());
	        return tokens;
	    }//end readFile

}//end class
